add_library(Xfont2 STATIC
        "libxfont/src/stubs/atom.c"
        "libxfont/src/stubs/libxfontstubs.c"
        "libxfont/src/util/fontaccel.c"
        "libxfont/src/util/fontnames.c"
        "libxfont/src/util/fontutil.c"
        "libxfont/src/util/fontxlfd.c"
        "libxfont/src/util/format.c"
        "libxfont/src/util/miscutil.c"
        "libxfont/src/util/patcache.c"
        "libxfont/src/util/private.c"
        "libxfont/src/util/utilbitmap.c"
        "libxfont/src/util/reallocarray.c"

        "libxfont/src/fontfile/bitsource.c"
        "libxfont/src/fontfile/bufio.c"
        "libxfont/src/fontfile/decompress.c"
        "libxfont/src/fontfile/defaults.c"
        "libxfont/src/fontfile/dirfile.c"
        "libxfont/src/fontfile/fileio.c"
        "libxfont/src/fontfile/filewr.c"
        "libxfont/src/fontfile/fontdir.c"
        "libxfont/src/fontfile/fontencc.c"
        "libxfont/src/fontfile/fontfile.c"
        "libxfont/src/fontfile/fontscale.c"
        "libxfont/src/fontfile/gunzip.c"
        "libxfont/src/fontfile/register.c"
        "libxfont/src/fontfile/renderers.c"
        "libxfont/src/fontfile/catalogue.c"

        "libxfont/src/bitmap/bitmap.c"
        "libxfont/src/bitmap/bitmapfunc.c"
        "libxfont/src/bitmap/bitmaputil.c"
        "libxfont/src/bitmap/bitscale.c"
        "libxfont/src/bitmap/fontink.c"
        "libxfont/src/bitmap/bdfread.c"
        "libxfont/src/bitmap/bdfutils.c"
        "libxfont/src/bitmap/pcfread.c"
        "libxfont/src/bitmap/pcfwrite.c"

        "libxfont/src/builtins/dir.c"
        "libxfont/src/builtins/file.c"
        "libxfont/src/builtins/fonts.c"
        "libxfont/src/builtins/fpe.c"
        "libxfont/src/builtins/render.c")
target_compile_options(Xfont2 PRIVATE
        ${common_compile_options}
        "-fvisibility=hidden"
        "-DHAVE_ERR_H"
        "-DHAVE_STDINT_H=1"
        "-DHAVE_READLINK"
        "-UHAVE_REALLOCARRAY"
        "-DHAVE_REALPATH"
        "-DHAVE_STRLCPY"
        "-DXFONT_BDFFORMAT=1"
        "-DXFONT_BITMAP=1"
        "-UXFONT_FREETYPE"
        "-DXFONT_PCFFORMAT=1"
        "-UXFONT_SNFFORMAT"
        "-UX_BZIP2_FONT_COMPRESSION"
        "-DX_GZIP_FONT_COMPRESSION=1"
        "-D_GNU_SOURCE=1"
        "-D_DEFAULT_SOURCE=1"
        "-D_BSD_SOURCE=1"
        "-DHAS_FCHOWN"
        "-DHAS_STICKY_DIR_BIT"
        "-D_XOPEN_SOURCE"
        "-DNOFILES_MAX=512")
target_include_directories(Xfont2 PRIVATE "libxfont" "libxfont/include" "libfontenc/include")
target_link_libraries(Xfont2 PUBLIC xorgproto)
